#include <sys/types.h>
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
int main()
{
    int q;
    char buffer[1024]={0};
    int fd1=open("./1.txt",O_RDWR|O_APPEND|O_CREAT,0777);
    int fd2=open("./demo.c",O_RDWR);
    while((q=read(fd2,buffer,sizeof(buffer)))!=0)
    {
        printf("%d\n",q);
        
        write(fd1,buffer,strlen(buffer));
        memset(buffer,0,sizeof(buffer));
    }
    
    close (fd1);
    close(fd2);
    return 0;


}